﻿using System.Collections.Generic;
using Freedom.Repository.Interface;
using Freedom.Repository.Models;
using Freedom.Services.Interface;

namespace Freedom.Services
{
    public class ProductService : IProductService
    {
        private readonly IProductRepository _productRepository;

        public ProductService(IProductRepository productRepository)
        {
            _productRepository = productRepository;
        }

        #region Implementation of IProductService

        public IEnumerable<Product> GetAllProducts()
        {
            return _productRepository.GetAllProducts();
        }

        public object GetPageProducts(int pagenum, int pagesize, string sortDataField = null, string sortOrder = "")
        {
            return new
                {
                    TotalRows = _productRepository.GetTotalCount(),
                    Rows = _productRepository.GetPageProducts(pagenum, pagesize, sortDataField, sortOrder)
                };
        }

        #endregion
    }
}
